package Demo.Controller;

import Demo.Pojo.User;
import Demo.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/user")
    public String demo1(Model model){

        List<User> userList = userService.getInfo();

        for(User user : userList){
            System.out.println(user);
        }

        model.addAttribute("userList",userList);
        return "usertable";
    }

    @RequestMapping(value = "/list")
    public String thymeleaf(Model model){

        List<User> userList = userService.getInfo();

        for(User user : userList){
            System.out.println(user);
        }

        model.addAttribute("userList",userList);
        return "userlist";
    }

}
